package com.hlk.utils.redis;

/**
 * redis的key
 *
 * @author hlk
 * @version 1.0
 * @date 2020-12-17 10:58
 */
public class RedisKeys {

    /**
     * 短信验证码key，根据IP
     *
     * @return
     */
    public static String getSmsCodeByIpKey(String ip) {
        return "mobile:smscode:" + ip;
    }

    /**
     * 短信验证码key，根据电话
     *
     * @return
     */
    public static String getSmsCodeByMobileKey(String mobile) {
        return "mobile:smscode:" + mobile;
    }

    /**
     * token的key
     *
     * @return
     */
    public static String getUserTokenKey(String userId) {
        return "redis:user:tokne:" + userId;
    }

    /**
     * 获取用户信息的key
     *
     * @param userId
     * @return
     */
    public static String getUserInfoKey(String userId) {
        return "redis:user:info:" + userId;
    }

    /**
     * 获取admin信息key
     *
     * @param adminId
     * @return
     */
    public static String getAdminTokenKey(String adminId) {
        return "redis:admin:token:" + adminId;
    }

    /**
     * 分类的key
     *
     * @return
     */
    public static String getCategoryKey() {
        return "redis:all:category";
    }

    /**
     * 永久存储是否阅读过的用户IP的key
     *
     * @param articleId
     * @param ip
     * @return
     */
    public static String getArticleReadedKey(String articleId, String ip) {
        return "redis:article:readed:" + articleId + ":" + ip;
    }

    /**
     * 文章阅读数的key
     *
     * @param articleId
     * @return
     */
    public static String getArticleReadCountsKey(String articleId) {
        return "redis:article:read:counts:" + articleId;
    }

    /**
     * 作家粉丝数key
     *
     * @param writerId
     * @return
     */
    public static String getWriterFansCountKey(String writerId) {
        return "redis:writer:fans:count:" + writerId;
    }

    /**
     * 我的关注数key
     *
     * @param userId
     * @return
     */
    public static String getMyFollowCountKey(String userId) {
        return "redis:my:follow:count:" + userId;
    }

    /**
     * 我的关注数key
     *
     * @param articleId
     * @return
     */
    public static String getArticleCommentCounts(String articleId) {
        return "redis:article:comment:count:" + articleId;
    }

    /**
     * 网关ip过滤的剩余时间key
     *
     * @param ip
     * @return
     */
    public static String getZuulIpLimitTimeKey(String ip) {
        return "zuul:ip:limit:" + ip;
    }

    /**
     * 网关保存的key
     *
     * @param ip
     * @return
     */
    public static String getZuulIpKey(String ip) {
        return "zuul:ip:" + ip;
    }
}
